package A0409;

import java.util.Objects;

public class Person {
    String name;
    String IdNumber; //代表身份证号

    @Override
    public boolean equals(Object o) {
        if (o == null || getClass() != o.getClass()) return false;
        Person person = (Person) o;
        return Objects.equals(IdNumber, person.IdNumber);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(IdNumber);//equals和hash一定要一起重写，为了不在哈希表中出现逻辑冲突
    }

    public Person(String name, String idNumber) {
        this.name = name;
        IdNumber = idNumber;
    }
}
